home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / scm / slib / scsh.init < prev    next >
Text File  |  1999-04-19  |  8KB  |  275 lines

  1. ;;; "scsh.init" Initialisation for SLIB for Scsh 0.5.1    -*-scheme-*-
  2. ;;; Author: Aubrey Jaffer
  3. ;;;
  4. ;;; This code is in the public domain.
  5.  
  6. ;;; (software-type) should be set to the generic operating system type.
  7. ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
  8.  
  9. (define (software-type) 'UNIX)
  10.  
  11. ;;; (scheme-implementation-type) should return the name of the scheme
  12. ;;; implementation loading this file.
  13.  
  14. (define (scheme-implementation-type) 'Scsh)
  15.  
  16. ;;; (scheme-implementation-home-page) should return a (string) URL
  17. ;;; (Uniform Resource Locator) for this scheme implementation's home
  18. ;;; page; or false if there isn't one.
  19.  
  20. (define (scheme-implementation-home-page)
  21.   "http://swissnet.ai.mit.edu/scsh/")
  22.  
  23. ;;; (scheme-implementation-version) should return a string describing
  24. ;;; the version the scheme implementation loading this file.
  25.  
  26. (define (scheme-implementation-version) "0.5.1")
  27.  
  28. ;;; (implementation-vicinity) should be defined to be the pathname of
  29. ;;; the directory where any auxillary files to your Scheme
  30. ;;; implementation reside.
  31.  
  32. (define (implementation-vicinity)
  33.   "/home/tomas/src/scsh-0.5.1/")
  34.  
  35. ;;; (library-vicinity) should be defined to be the pathname of the
  36. ;;; directory where files of Scheme library functions reside.
  37.  
  38. (define (library-vicinity)
  39.   "/home/tomas/src/slib2b1/")
  40.  
  41. ;;; (home-vicinity) should return the vicinity of the user's HOME
  42. ;;; directory, the directory which typically contains files which
  43. ;;; customize a computer environment for a user.
  44.  
  45. (define home-vicinity
  46.   (let ((home-path (getenv "HOME")))
  47.     (lambda () home-path)))
  48.  
  49. ;;; *FEATURES* should be set to a list of symbols describing features
  50. ;;; of this implementation.  Suggestions for features are:
  51.  
  52. (define *features*
  53.       '(
  54.     source                ;can load scheme source files
  55.                     ;(slib:load-source "filename")
  56. ;    compiled            ;can load compiled files
  57.                     ;(slib:load-compiled "filename")
  58.     rev4-report            ;conforms to
  59. ;    rev3-report            ;conforms to
  60.     ieee-p1178            ;conforms to
  61. ;    sicp                ;runs code from Structure and
  62.                     ;Interpretation of Computer
  63.                     ;Programs by Abelson and Sussman.
  64.     rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  65.                     ;LIST->STRING, STRING-COPY,
  66.                     ;STRING-FILL!, LIST->VECTOR,
  67.                     ;VECTOR->LIST, and VECTOR-FILL!
  68. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  69.                     ;SUBSTRING-MOVE-RIGHT!,
  70.                     ;SUBSTRING-FILL!,
  71.                     ;STRING-NULL?, APPEND!, 1+,
  72.                     ;-1+, <?, <=?, =?, >?, >=?
  73.     multiarg/and-            ;/ and - can take more than 2 args.
  74.     multiarg-apply            ;APPLY can take more than 2 args.
  75.     rationalize
  76.     delay                ;has DELAY and FORCE
  77.     with-file            ;has WITH-INPUT-FROM-FILE and
  78.                     ;WITH-OUTPUT-FROM-FILE
  79. ;    string-port            ;has CALL-WITH-INPUT-STRING and
  80.                     ;CALL-WITH-OUTPUT-STRING
  81. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  82.     char-ready?
  83.     macro                ;has R4RS high level macros
  84. ;    defmacro            ;has Common Lisp DEFMACRO
  85.     eval                ;proposed 2-arugment eval
  86. ;    record                ;has user defined data structures
  87.     values                ;proposed multiple values
  88.     dynamic-wind            ;proposed dynamic-wind
  89. ;    ieee-floating-point        ;conforms to
  90.     full-continuation        ;can return multiple times
  91. ;    object-hash            ;has OBJECT-HASH
  92.  
  93. ;    sort
  94. ;    queue                ;queues
  95. ;    pretty-print
  96. ;    object->string
  97.     format
  98. ;    trace                ;has macros: TRACE and UNTRACE
  99. ;    compiler            ;has (COMPILER)
  100. ;    ed                ;(ED) is editor
  101. ;    system                ;posix (system <string>)
  102.     getenv                ;posix (getenv <string>)
  103. ;    program-arguments        ;returns list of strings (argv)
  104. ;    Xwindows            ;X support
  105. ;    curses                ;screen management package
  106. ;    termcap                ;terminal description package
  107. ;    terminfo            ;sysV terminal description
  108. ;    current-time            ;returns time in seconds since 1/1/1970
  109.     ))
  110.  
  111. ;;; (OUTPUT-PORT-WIDTH <port>)
  112. (define (output-port-width . arg) 79)
  113.  
  114. ;;; (OUTPUT-PORT-HEIGHT <port>)
  115. (define (output-port-height . arg) 24)
  116.  
  117. ;;; (CURRENT-ERROR-PORT)
  118. (define current-error-port error-output-port)
  119.  
  120. ;;; (TMPNAM) makes a temporary file name.
  121. (define (tmpnam)
  122.   (create-temp-file "slib_"))
  123.  
  124. ;;; (FILE-EXISTS? <string>)
  125. ;(define (file-exists? f) #f)
  126.  
  127. ;;; (DELETE-FILE <string>)
  128. ;(define (delete-file f) #f)
  129.  
  130. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  131. ;;; use this definition if your system doesn't have such a procedure.
  132. ;(define (force-output . arg) #t)
  133.  
  134. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  135. ;;; port versions of CALL-WITH-*PUT-FILE.
  136.  
  137. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  138. ;;; be returned by CHAR->INTEGER.
  139. (define char-code-limit 256)
  140.  
  141. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  142. (define most-positive-fixnum #x0FFFFFFF)
  143.  
  144. ;;; Return argument
  145. (define (identity x) x)
  146.  
  147. ;;; SLIB:EVAL is single argument eval using the top-level (user) environment.
  148.  
  149. ; [s48 has two argument eval]
  150. (define (slib:eval form)
  151.   (eval form (interaction-environment)))
  152.  
  153. ;;; If your implementation provides R4RS macros:
  154. (define macro:eval slib:eval)
  155. (define macro:load load)
  156.  
  157. (define *defmacros*
  158.   (list (cons 'defmacro
  159.           (lambda (name parms . body)
  160.         `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
  161.                       *defmacros*))))))
  162.  
  163. (define (defmacro? m) (and (assq m *defmacros*) #t))
  164.  
  165. (define (macroexpand-1 e)
  166.   (if (pair? e) (let ((a (car e)))
  167.           (cond ((symbol? a) (set! a (assq a *defmacros*))
  168.                      (if a (apply (cdr a) (cdr e)) e))
  169.             (else e)))
  170.       e))
  171.  
  172. (define (macroexpand e)
  173.   (if (pair? e) (let ((a (car e)))
  174.           (cond ((symbol? a)
  175.              (set! a (assq a *defmacros*))
  176.              (if a (macroexpand (apply (cdr a) (cdr e))) e))
  177.             (else e)))
  178.       e))
  179.  
  180. (define gentemp
  181.   (let ((*gensym-counter* -1))
  182.     (lambda ()
  183.       (set! *gensym-counter* (+ *gensym-counter* 1))
  184.       (string->symbol
  185.        (string-append "slib:G" (number->string *gensym-counter*))))))
  186.  
  187. (define base:eval slib:eval)
  188. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  189. (define (defmacro:expand* x)
  190.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  191.  
  192. (define (defmacro:load pathname)
  193.   (slib:eval-load pathname defmacro:eval))
  194.  
  195. (define (slib:eval-load pathname evl)
  196.   (if (not (file-exists? pathname))
  197.       (set! pathname (string-append pathname (scheme-file-suffix))))
  198.   (call-with-input-file pathname
  199.     (lambda (port)
  200.       (let ((old-load-pathname *load-pathname*))
  201.     (set! *load-pathname* pathname)
  202.     (do ((o (read port) (read port)))
  203.         ((eof-object? o))
  204.       (evl o))
  205.     (set! *load-pathname* old-load-pathname)))))
  206.  
  207. (define slib:warn
  208.   (lambda args
  209.     (let ((port (current-error-port)))
  210.       (display "Warn: " port)
  211.       (for-each (lambda (x) (display x port)) args))))
  212.  
  213. ;;; define an error procedure for the library
  214. (define slib:error error)
  215.  
  216. ;;; define these as appropriate for your system.
  217. (define slib:tab (ascii->char 9))
  218. (define slib:form-feed (ascii->char 12))
  219.  
  220. ;;; Support for older versions of Scheme.  Not enough code for its own file.
  221. (define (last-pair l) (if (pair? (cdr l)) (last-pair (cdr l)) l))
  222. (define t #t)
  223. (define nil #f)
  224.  
  225. (define append! append)
  226.  
  227. ;;; Define these if your implementation's syntax can support it and if
  228. ;;; they are not already defined.
  229.  
  230. (define (1+ n) (+ n 1))
  231. (define (-1+ n) (+ n -1))
  232. (define 1- -1+)
  233.  
  234. (define in-vicinity string-append)
  235.  
  236. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  237. ;;; return if exitting not supported.
  238. (define slib:exit (lambda args #f))
  239.  
  240. ;;; Here for backward compatability
  241. (define scheme-file-suffix
  242.   (let ((suffix (case (software-type)
  243.           ((NOSVE) "_scm")
  244.           (else ".scm"))))
  245.     (lambda () suffix)))
  246.  
  247. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  248. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  249.  
  250. (define (slib:load-source f) (load (string-append f ".scm")))
  251.  
  252. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  253. ;;; by compiling "foo.scm" if this implementation can compile files.
  254. ;;; See feature 'COMPILED.
  255.  
  256. (define slib:load-compiled load)
  257.  
  258. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  259.  
  260. (define slib:load slib:load-source)
  261.  
  262. ;;; Scheme48 complains that these are not defined (even though they
  263. ;;; won't be called until they are).
  264. (define synclo:load #f)
  265. (define syncase:load #f)
  266. (define macwork:load #f)
  267. (define transcript-on #f)
  268. (define transcript-off #f)
  269.  
  270. (define array? #f)
  271. (define record? #f)
  272. (define sort! #f)
  273.  
  274. (slib:load (in-vicinity (library-vicinity) "require"))
  275.